import { generate } from '@/api/live/live';
import { EventBus } from '@/event-bus.js';
import { ScriptType } from '@/enum/enums';
export const randomAudioMatch = {
  data() {
    return {

    };
  },
  created() {
    EventBus.$on("randomAudioMatchSendWebSocket", () => {
      if (this.randomAudioSetting.open) {
        this.randomAudio();
      }
    });
  },
  beforeDestroy() {
    EventBus.$off('randomAudioMatchSendWebSocket');
  },
  mounted() { },
  computed: {
    pageConfig() {
      return this.$store.state.page.config;
    },
    randomAudioSetting() {
      return this.pageConfig.randomAudioSetting;
    },
  },
  methods: {
    randomAudio() {
      generate({
        userName: '',
        text: '',
        scriptType: ScriptType.RANDOM_AUDIO.code,
      });
    }
  }
}
